package com.lovo.controller;

import com.lovo.bean.StudentBean;
import com.lovo.result.ResponseResult;
import com.lovo.service.IStudentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

@RestController
@RequestMapping("/students")
public class StudentController {
    @Resource
    private IStudentService studentService;
    @GetMapping
    @ResponseResult
    public Object showAll(){
        return studentService.selectAll();
    }
    @GetMapping("/{id}")
    @ResponseResult
    public Object showById(@PathVariable("id") Long id){
        return "showById:"+id;
    }
    @PostMapping
    @ResponseResult
    public Object add(@RequestBody @Valid StudentBean studentBean){
        System.out.println("add:"+studentBean);
        return "add";
    }
    @PutMapping("/{id}")
    public String update(@PathVariable("id") Long id,@RequestBody StudentBean studentBean){
        System.out.println("update:"+studentBean);
        return "update";
    }
    @DeleteMapping("/{id}")
    public String delete(@PathVariable("id") Long id){
        System.out.println("delete:"+id);
        return "delete";
    }
}
